import grails.util.GrailsUtil
import nbcondominios.User
import nbcondominios.Residentes

class BootStrap {
    def init = { servletContext ->
        switch(GrailsUtil.environment){
            case "development":
            def admin = new User(login:"admin",
                password:"password",
                role:"admin")
            admin.save()
            if(admin.hasErrors()){
                println admin.errors
            }
            def user = new User(login:"user",
                password:"password",
                role:"user")
            user.save()
            if(user.hasErrors()){
                println user.errors
            }
            break
            case "production":
            def admin = new User(login:"admin",
                password:"password",
                role:"admin")
            admin.save()
            if(admin.hasErrors()){
                println admin.errors
            }
            def user = new User(login:"user",
                password:"password",
                role:"user")
            user.save()
            if(user.hasErrors()){
                println user.errors
            }    
            break
        }
        def destroy = {
        }
    }
}
